<?php
	/**
	 * This is the abstract Panel class for the List All functionality
	 * of the ComSchool class.  This code-generated class
	 * contains a datagrid to display an HTML page that can
	 * list a collection of ComSchool objects.  It includes
	 * functionality to perform pagination and sorting on columns.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QPanel which extends this ComSchoolListPanelBase
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent re-
	 * code generation.
	 * 
	 * @package My QCubed Application
	 * @subpackage Drafts
	 * 
	 */
	class ComSchoolListPanel extends QPanel {
		// Local instance of the Meta DataGrid to list ComSchools
		public $dtgComSchools;

		// Other public QControls in this panel
		public $btnCreateNew;
		public $pxyEdit;

		// Callback Method Names
		protected $strSetEditPanelMethod;
		protected $strCloseEditPanelMethod;
		
		public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) {
			// Call the Parent
			try {
				parent::__construct($objParentObject, $strControlId);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
                        
			// Record Method Callbacks
			$this->strSetEditPanelMethod = $strSetEditPanelMethod;
			$this->strCloseEditPanelMethod = $strCloseEditPanelMethod;

			// Setup the Template
			$this->strTemplate = __DOCROOT__.__COM__ . '/tpl/qepanel_list.tpl.php';
			// Instantiate the Meta DataGrid
			$this->dtgComSchools = new ComSchoolDataGrid($this);

                        $this->dtgComSchools->AdditionalConditions = QQ::Equal(QQN::ComSchool()->SchoolId, $_SESSION['OrgId']) ;
			// Style the DataGrid (if desired)
			$this->dtgComSchools->CssClass = 'datagrid';
			$this->dtgComSchools->AlternateRowStyle->CssClass = 'alternate';

			// Add Pagination (if desired)
			$this->dtgComSchools->Paginator = new QPaginator($this->dtgComSchools);
			$this->dtgComSchools->ItemsPerPage = 8;

			// Use the MetaDataGrid functionality to add Columns for this datagrid

			// Create an Edit Column
                        $this->dtgComSchools->AddRowAction(new QMouseOverEvent(), new QCssClassAction('selectedStyle'));
                        $this->dtgComSchools->AddRowAction(new QMouseOutEvent(), new QCssClassAction());
                        $this->dtgComSchools->RowActionParameterHtml = '<?= $_ITEM->Id ?>';
                        $this->dtgComSchools->AddRowAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEdit_Click'));
                       
			// Create the Other Columns (note that you can use strings for com_school's properties, or you
			// can traverse down QQN::com_school() to display fields that are down the hierarchy)
                        $this->dtgComSchools->AddColumn(new QDataGridColumn('Row Number', '<?= ($_CONTROL->CurrentRowIndex + 1) ?>'));
			$this->dtgComSchools->MetaAddColumn('Date');
			$this->dtgComSchools->MetaAddColumn(QQN::ComSchool()->EuserObject);
			//$this->dtgComSchools->MetaAddColumn(QQN::ComSchool()->School);
			$this->dtgComSchools->MetaAddTypeColumn('Type', 'ComScboolType');




			// Setup the Create New button
			$this->btnCreateNew = new QButton($this);
			$this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('ComSchool');
			$this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
		}
/*ComMainform,c19,6*/
		public function pxyEdit_Click($strFormId, $strControlId, $strParameter) {
			$strParameterArray = explode(',', $strParameter);
                        $_SESSION['ComSchoolId']= $strParameterArray[0];

                            //Clear All Panel to before creating new
                        $this->objForm->CloseAllPane();
                            //ComSchool Edit
			$objEditPanel = new ComSchoolEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0]);
			$strMethodName = $this->strSetEditPanelMethod;
			$this->objForm->$strMethodName($objEditPanel, "pnlComEdit");
                            //Com Note list
                        $objEditPanel = new ComNoteListPanel ($this, 'SetEditPane', 'ClosePane');
                        $strMethodName = $this->strSetEditPanelMethod;
			$this->objForm->$strMethodName($objEditPanel, "pnlComNoteList");

                }

		public function btnCreateNew_Click($strFormId, $strControlId, $strParameter) {
                                                //Clear All Panel to before creating new
                        $this->objForm->CloseAllPane();
			$objEditPanel = new ComSchoolEditPanel($this, $this->strCloseEditPanelMethod, null);
			$strMethodName = $this->strSetEditPanelMethod;
			$this->objForm->$strMethodName($objEditPanel, "pnlComEdit");
		}
	}
?>